import axios from "axios";
//封装网络请求
function startRequestOnly(param){
  return axios({...param}).then(res=>res.data).catch(err=>err)
}

//封装网络请求可以用来接收多个
async function network(params){
  if(params instanceof Array){
    //判断数组是否传入多个数据  定义数组存储多个数据
    let results = [];
    for(let index in params){
      let result = await startRequestOnly(params[index]);
      results.push(result);
    }
    return results;
  }else{
    return await startRequestOnly(params)
  }
}

//导入网络请求
export default network;